'use strict';

const info = require("./info");

module.exports = app => {
  const {
    STRING,
    INTEGER
  } = app.Sequelize;

  const User = app.model.define('users', {
    id: {
      type: INTEGER,
      primaryKey: true,
      autoIncrement: true
    },
    username: STRING(30),
    password: STRING(100),
    created_at: INTEGER,
    state: INTEGER,
  });
  User.associate = function () {
    // 与Info存在一对多关系，所以是hasOne()
    app.model.User.hasOne(app.model.Info, {
      foreignKey: 'user_id'
    });

    
  }

  return User;
};